// pages/samplestate/samplestate.js
import baseteam from '~/utils/teamleader.js'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        keyword:'',
        pags:1,
        pageSize:10,
        state:999,
        yangpinnumb:{}
    },
    bindserach(){
        this.setData({
            pags:1,
        })
        this.getourderslist()
    },
    tabsChange(item){
        this.setData({
            state:item.detail.name
        })
        this.getourderslist()
    },
    searChange(item){
        this.setData({
            keyword:item.detail
        })
    },
    clearChange(item){
        this.setData({
            keyword:'',
            pags:1,
        })
        this.getourderslist()
    },
    nextorder(item){
        console.log(item)
        wx.navigateTo({
          url: `/logistics/team_order_details/team_order_details?orderbyid=${item.currentTarget.dataset.detailsid}`,

        })
    },
    async getallnumb(){
        let fivedata = await baseteam.samplemanag()
        if(fivedata.message == "操作成功"){
            this.setData({
                yangpinnumb:fivedata.data.result
            })
        }
    },
    async getourderslist(){
        let newstate = this.data.state
        if (newstate == 999) {
            newstate=''
        }
        let reqdata = {
            "keyword": this.data.keyword,
            "current": this.data.pags,
            "pageSize": this.data.pageSize,
            "status": newstate
        }
        let resdata = await baseteam.myourders(reqdata)
        console.log('resdata',resdata);
        if(resdata.message == "操作成功"){
            this.setData({
                ourderslist:resdata.data.result.records
            })
        }
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.setData({
            state:options.state
        })
        this.getallnumb()
        this.getourderslist()
    },
    nextsuppliersample(){
        wx.navigateTo({
          // url: '../../pages/suppliersample/suppliersample',
          url: '/pages/suppliersample/suppliersample',

        })
    },
    nextview(){
        wx.navigateTo({
          // url: '../../pages/viewlogistics/viewlogistics',
          url: '/pages/viewlogistics/viewlogistics',

        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        this.getallnumb()
        this.getourderslist()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})